#include "mario.h"
#include <winalleg.h>

int CALLBACK WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow)
{
    try
    {
        // Inicjalizacja.
        Graphics::GetInstance()->Initialize(800,600,32);
        Input::GetInstance()->Initialize();
        Game::GetInstance()->Initialize();

        // Gracz.
        //player = new Player("Player1",3);
        //player->PrintDebugInfo();
        //player->Render();

        // TODO: Nie rzucaj wyjatkiem :)
        //throw new GameException("This game is still under development.\nCan't go any further. Sorry, bye.");

		//nscjalizacja menu

        // Glowna petla.

		//Game::GetInstance()->PushGameState(Menu::GameState);

		//Wrzucenie menu na stos
		Menu *m = new Menu();
		m->Initialize();
		Game::GetInstance()->PushGameState(m);

        while (Game::GetInstance()->IsRunning())
        {
            Game::GetInstance()->Update();
        }
	
        // Zamykanie.
        Input::GetInstance()->Shutdown();
        Graphics::GetInstance()->Shutdown();
        return 0;
    }
    catch (GameException* gameException)
    {
        MessageBox(NULL, gameException->what(), "Fatal Error", MB_ICONERROR | MB_OK);
        return 1;
    }
}
